<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Reference</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Duplex</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>


<h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
  <li><a href="../modules/Duplex.Application.html">Duplex.Application</a></li>
  <li><a href="../modules/Duplex.Applications.Effect.html">Duplex.Applications.Effect</a></li>
  <li><a href="../modules/Duplex.Applications.GridPie.html">Duplex.Applications.GridPie</a></li>
  <li><a href="../modules/Duplex.Applications.Hydra.html">Duplex.Applications.Hydra</a></li>
  <li><a href="../modules/Duplex.Applications.Instrument.html">Duplex.Applications.Instrument</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.GridLayout.html">Duplex.Applications.Keyboard.GridLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.HarmonicLayout.html">Duplex.Applications.Keyboard.Layouts.HarmonicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.IsomorphicLayout.html">Duplex.Applications.Keyboard.Layouts.IsomorphicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.PianoLayout.html">Duplex.Applications.Keyboard.Layouts.PianoLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.html">Duplex.Applications.Keyboard</a></li>
  <li><a href="../modules/Duplex.Applications.Matrix.html">Duplex.Applications.Matrix</a></li>
  <li><a href="../modules/Duplex.Applications.Metronome.html">Duplex.Applications.Metronome</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.Bindings.html">Duplex.Applications.MidiActions.Bindings</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.html">Duplex.Applications.MidiActions</a></li>
  <li><a href="../modules/Duplex.Applications.Mixer.html">Duplex.Applications.Mixer</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_group.html">Duplex.Applications.Mlrx.Mlrx_group</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_note.html">Duplex.Applications.Mlrx.Mlrx_note</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_pos.html">Duplex.Applications.Mlrx.Mlrx_pos</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_track.html">Duplex.Applications.Mlrx.Mlrx_track</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.html">Duplex.Applications.Mlrx</a></li>
  <li><a href="../modules/Duplex.Applications.Navigator.html">Duplex.Applications.Navigator</a></li>
  <li><a href="../modules/Duplex.Applications.NotesOnWheels.html">Duplex.Applications.NotesOnWheels</a></li>
  <li><a href="../modules/Duplex.Applications.PatternCursor.html">Duplex.Applications.PatternCursor</a></li>
  <li><a href="../modules/Duplex.Applications.PatternSequence.html">Duplex.Applications.PatternSequence</a></li>
  <li><a href="../modules/Duplex.Applications.Recorder.html">Duplex.Applications.Recorder</a></li>
  <li><a href="../modules/Duplex.Applications.Repeater.html">Duplex.Applications.Repeater</a></li>
  <li><a href="../modules/Duplex.Applications.Rotate.html">Duplex.Applications.Rotate</a></li>
  <li><a href="../modules/Duplex.Applications.StepSequencer.html">Duplex.Applications.StepSequencer</a></li>
  <li><a href="../modules/Duplex.Applications.SwitchConfiguration.html">Duplex.Applications.SwitchConfiguration</a></li>
  <li><a href="../modules/Duplex.Applications.TestPad.html">Duplex.Applications.TestPad</a></li>
  <li><a href="../modules/Duplex.Applications.TrackSelector.html">Duplex.Applications.TrackSelector</a></li>
  <li><a href="../modules/Duplex.Applications.Transport.html">Duplex.Applications.Transport</a></li>
  <li><a href="../modules/Duplex.Applications.UIButtonTest.html">Duplex.Applications.UIButtonTest</a></li>
  <li><a href="../modules/Duplex.Applications.XYPad.html">Duplex.Applications.XYPad</a></li>
  <li><a href="../modules/Duplex.Automation.html">Duplex.Automation</a></li>
  <li><a href="../modules/Duplex.Browser.html">Duplex.Browser</a></li>
  <li><a href="../modules/Duplex.BrowserProcess.html">Duplex.BrowserProcess</a></li>
  <li><a href="../modules/Duplex.Canvas.html">Duplex.Canvas</a></li>
  <li><a href="../modules/Duplex.CanvasPoint.html">Duplex.CanvasPoint</a></li>
  <li><a href="../modules/Duplex.ControlMap.html">Duplex.ControlMap</a></li>
  <li><a href="../modules/Duplex.Device.html">Duplex.Device</a></li>
  <li><a href="../modules/Duplex.Display.html">Duplex.Display</a></li>
  <li><a href="../modules/Duplex.Globals.html">Duplex.Globals</a></li>
  <li><a href="../modules/Duplex.Message.html">Duplex.Message</a></li>
  <li><strong>Duplex.MessageStream</strong></li>
  <li><a href="../modules/Duplex.MidiDevice.html">Duplex.MidiDevice</a></li>
  <li><a href="../modules/Duplex.OscClient.html">Duplex.OscClient</a></li>
  <li><a href="../modules/Duplex.OscDevice.html">Duplex.OscDevice</a></li>
  <li><a href="../modules/Duplex.OscVoiceMgr.html">Duplex.OscVoiceMgr</a></li>
  <li><a href="../modules/Duplex.Preferences.html">Duplex.Preferences</a></li>
  <li><a href="../modules/Duplex.ProcessSlicer.html">Duplex.ProcessSlicer</a></li>
  <li><a href="../modules/Duplex.RoamingDSP.html">Duplex.RoamingDSP</a></li>
  <li><a href="../modules/Duplex.Scheduler.html">Duplex.Scheduler</a></li>
  <li><a href="../modules/Duplex.StateController.html">Duplex.StateController</a></li>
  <li><a href="../modules/Duplex.UIButton.html">Duplex.UIButton</a></li>
  <li><a href="../modules/Duplex.UIButtonStrip.html">Duplex.UIButtonStrip</a></li>
  <li><a href="../modules/Duplex.UIComponent.html">Duplex.UIComponent</a></li>
  <li><a href="../modules/Duplex.UIKey.html">Duplex.UIKey</a></li>
  <li><a href="../modules/Duplex.UIKeyPressure.html">Duplex.UIKeyPressure</a></li>
  <li><a href="../modules/Duplex.UILabel.html">Duplex.UILabel</a></li>
  <li><a href="../modules/Duplex.UIPad.html">Duplex.UIPad</a></li>
  <li><a href="../modules/Duplex.UIPitchBend.html">Duplex.UIPitchBend</a></li>
  <li><a href="../modules/Duplex.UISlider.html">Duplex.UISlider</a></li>
  <li><a href="../modules/Duplex.UISpinner.html">Duplex.UISpinner</a></li>
  <li><a href="../modules/Duplex.WidgetHooks.html">Duplex.WidgetHooks</a></li>
  <li><a href="../modules/Duplex.WidgetKeyboard.html">Duplex.WidgetKeyboard</a></li>
  <li><a href="../modules/Duplex.html">Duplex</a></li>
  <li><a href="../modules/main.html">main</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>Duplex.MessageStream</code></h1>
<p>Recieve messages from connected devices and the virtual control surface.</p>
<p>
<p> </p>

<p>After the type of event has been determined, the resulting Message is then directed towards relevant UIComponent event-listeners, such as DEVICE<em>EVENT.BUTTON</em>PRESSED. </p>

<p>A device can only belong to a single stream, but nothing stops the stream from recieving it's input from several devices.  </p>


<h3>Changes</h3>

<p>  0.99.3</p>
<pre><code>- Ability to cache multiple matched ui-components (implemented as queue)
- Integration with StateController
</code></pre>

<p>  0.99.1</p>
<pre><code>- FIXME Caching can break multiple UIComponents listening to the same signal
</code></pre>

<p>  0.98.27</p>
<pre><code>- Caching: improve performance when many controls are present
</code></pre>

<p>  0.96</p>
<pre><code>- New Message property: is_note_off - distinguish between note-on/note-off
</code></pre>

<p>  0.9</p>
<pre><code>- First release
</code></pre>

</p>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#__init">__init (process)</a></td>
	<td class="summary">Initialize the MessageStream class</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#on_idle">on_idle ()</a></td>
	<td class="summary">The MessageStream idle time method, checks for held buttons</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#input_message">input_message (msg)</a></td>
	<td class="summary">Here we receive a message from the device, and pass it to all the relevant
 UIComponents.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#add_listener">add_listener (obj, evt_type, handler)</a></td>
	<td class="summary">Register an event listener</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#remove_listener">remove_listener (obj, evt_type)</a></td>
	<td class="summary">Remove event listener from previously attached UIComponent</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_handle_or_pass">_handle_or_pass (msg, listeners, evt_type)</a></td>
	<td class="summary">Handle or pass: invoke event handlers or pass on to Renoise as MIDI
 (only valid msg context is DEVICE<em>MESSAGE.MIDI</em>NOTE)</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self._temp_cache">self._temp_cache</a></td>
	<td class="summary">contains entries that should be cached once a series
 of messages have been received</td>
	</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self.process">self.process</a></td>
	<td class="summary">(<a href="../modules/Duplex.BrowserProcess.html#">Duplex.BrowserProcess</a>)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.change_listeners">self.change_listeners</a></td>
	<td class="summary">(table) listeners for faders,dials,xy pads</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.press_listeners">self.press_listeners</a></td>
	<td class="summary">(table) listeners for buttons</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.hold_listeners">self.hold_listeners</a></td>
	<td class="summary">(table) listeners for buttons</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.release_listeners">self.release_listeners</a></td>
	<td class="summary">(table) listeners for buttons</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.key_press_listeners">self.key_press_listeners</a></td>
	<td class="summary">(table) listeners for keys</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.key_hold_listeners">self.key_hold_listeners</a></td>
	<td class="summary">(table) listeners for keys</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.key_release_listeners">self.key_release_listeners</a></td>
	<td class="summary">(table) listeners for keys</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.pitch_change_listeners">self.pitch_change_listeners</a></td>
	<td class="summary">(table) listeners for keys</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.channel_pressure_listeners">self.channel_pressure_listeners</a></td>
	<td class="summary">(table) listeners for keys</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.button_hold_time">self.button_hold_time</a></td>
	<td class="summary">(number) how long before triggering <code>hold</code> event</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.current_msg">self.current_msg</a></td>
	<td class="summary">(<a href="../modules/Duplex.Message.html#">Duplex.Message</a>) most recent message</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.pressed_buttons">self.pressed_buttons</a></td>
	<td class="summary">(table of <a href="../modules/Duplex.Message.html#">Duplex.Message</a>) pressed buttons in order of arrival</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.message_cache">self.message_cache</a></td>
	<td class="summary">
<p>table, containing each type of event and messages by value:</p>
<pre><code>[DEVICE_EVENT.BUTTON_RELEASED] = {
  "F#4|Ch1" = {[UIComponent instance],...}
},...
</code></pre>
</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.queued_messages">self.queued_messages</a></td>
	<td class="summary">how many messages a device is going to send</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>
    <dl class="function">
    <dt>
    <a name = "__init"></a>
    <strong>__init (process)</strong>
    </dt>
    <dd>
    Initialize the MessageStream class


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">process</span>
         (<a href="../modules/Duplex.BrowserProcess.html#">Duplex.BrowserProcess</a>)
        </li>
    </ul>





</dd>
    <dt>
    <a name = "on_idle"></a>
    <strong>on_idle ()</strong>
    </dt>
    <dd>
    The MessageStream idle time method, checks for held buttons







</dd>
    <dt>
    <a name = "input_message"></a>
    <strong>input_message (msg)</strong>
    </dt>
    <dd>
    Here we receive a message from the device, and pass it to all the relevant
 UIComponents.  If a listener's handler method actively reject the message
 (by explicitly returning false in the event-handling method), we instead
 (can choose to) pass the message on to Renoise as a MIDI message


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg</span>
         (<a href="../modules/Duplex.Message.html#">Duplex.Message</a>)
        </li>
    </ul>





</dd>
    <dt>
    <a name = "add_listener"></a>
    <strong>add_listener (obj, evt_type, handler)</strong>
    </dt>
    <dd>
    Register an event listener


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">obj</span>
         (<a href="../modules/Duplex.UIComponent.html#">Duplex.UIComponent</a>)
        </li>
        <li><span class="parameter">evt_type</span>
         (<a href="../modules/Duplex.Globals.html#DEVICE_EVENT">Duplex.Globals.DEVICE_EVENT</a>)
        </li>
        <li><span class="parameter">handler</span>
         (function) reference to the handling method
        </li>
    </ul>





</dd>
    <dt>
    <a name = "remove_listener"></a>
    <strong>remove_listener (obj, evt_type)</strong>
    </dt>
    <dd>
    Remove event listener from previously attached UIComponent


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">obj</span>
         (<a href="../modules/Duplex.UIComponent.html#">Duplex.UIComponent</a>)
        </li>
        <li><span class="parameter">evt_type</span>
         (<a href="../modules/Duplex.Globals.html#DEVICE_EVENT">Duplex.Globals.DEVICE_EVENT</a>)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        (bool) true if successful, false if not
    </ol>




</dd>
    <dt>
    <a name = "_handle_or_pass"></a>
    <strong>_handle_or_pass (msg, listeners, evt_type)</strong>
    </dt>
    <dd>
    Handle or pass: invoke event handlers or pass on to Renoise as MIDI
 (only valid msg context is DEVICE<em>MESSAGE.MIDI</em>NOTE)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg</span>
         (<a href="../modules/Duplex.Message.html#">Duplex.Message</a>)
        </li>
        <li><span class="parameter">listeners</span>
         (table), listener methods
        </li>
        <li><span class="parameter">evt_type</span>
         (<a href="../modules/Duplex.Globals.html#DEVICE_EVENT">Duplex.Globals.DEVICE_EVENT</a>)
        </li>
    </ul>





</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>
    <dl class="function">
    <dt>
    <a name = "self._temp_cache"></a>
    <strong>self._temp_cache</strong>
    </dt>
    <dd>
    contains entries that should be cached once a series
 of messages have been received







</dd>
</dl>
    <h2><a name="Fields"></a>Fields</h2>
    <dl class="function">
    <dt>
    <a name = "self.process"></a>
    <strong>self.process</strong>
    </dt>
    <dd>
    (<a href="../modules/Duplex.BrowserProcess.html#">Duplex.BrowserProcess</a>)







</dd>
    <dt>
    <a name = "self.change_listeners"></a>
    <strong>self.change_listeners</strong>
    </dt>
    <dd>
    (table) listeners for faders,dials,xy pads







</dd>
    <dt>
    <a name = "self.press_listeners"></a>
    <strong>self.press_listeners</strong>
    </dt>
    <dd>
    (table) listeners for buttons







</dd>
    <dt>
    <a name = "self.hold_listeners"></a>
    <strong>self.hold_listeners</strong>
    </dt>
    <dd>
    (table) listeners for buttons







</dd>
    <dt>
    <a name = "self.release_listeners"></a>
    <strong>self.release_listeners</strong>
    </dt>
    <dd>
    (table) listeners for buttons







</dd>
    <dt>
    <a name = "self.key_press_listeners"></a>
    <strong>self.key_press_listeners</strong>
    </dt>
    <dd>
    (table) listeners for keys







</dd>
    <dt>
    <a name = "self.key_hold_listeners"></a>
    <strong>self.key_hold_listeners</strong>
    </dt>
    <dd>
    (table) listeners for keys







</dd>
    <dt>
    <a name = "self.key_release_listeners"></a>
    <strong>self.key_release_listeners</strong>
    </dt>
    <dd>
    (table) listeners for keys







</dd>
    <dt>
    <a name = "self.pitch_change_listeners"></a>
    <strong>self.pitch_change_listeners</strong>
    </dt>
    <dd>
    (table) listeners for keys







</dd>
    <dt>
    <a name = "self.channel_pressure_listeners"></a>
    <strong>self.channel_pressure_listeners</strong>
    </dt>
    <dd>
    (table) listeners for keys







</dd>
    <dt>
    <a name = "self.button_hold_time"></a>
    <strong>self.button_hold_time</strong>
    </dt>
    <dd>
    (number) how long before triggering <code>hold</code> event







</dd>
    <dt>
    <a name = "self.current_msg"></a>
    <strong>self.current_msg</strong>
    </dt>
    <dd>
    (<a href="../modules/Duplex.Message.html#">Duplex.Message</a>) most recent message







</dd>
    <dt>
    <a name = "self.pressed_buttons"></a>
    <strong>self.pressed_buttons</strong>
    </dt>
    <dd>
    (table of <a href="../modules/Duplex.Message.html#">Duplex.Message</a>) pressed buttons in order of arrival







</dd>
    <dt>
    <a name = "self.message_cache"></a>
    <strong>self.message_cache</strong>
    </dt>
    <dd>

<p>table, containing each type of event and messages by value:</p>
<pre><code>[DEVICE_EVENT.BUTTON_RELEASED] = {
  "F#4|Ch1" = {[UIComponent instance],...}
},...
</code></pre>








</dd>
    <dt>
    <a name = "self.queued_messages"></a>
    <strong>self.queued_messages</strong>
    </dt>
    <dd>
    how many messages a device is going to send







</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.2</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
